﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Interface_Tier;
using Transfer_Object_Tier;

namespace eSolution_HRMSS.Winforms.QuaTrinhLamViec
{
    public partial class FR_ThemThongTinCongTac : DevExpress.XtraEditors.XtraForm
    {
        IHRM_PROCESS_ASSIGNMENTData _IHRM_PROCESS_ASSIGNMENTData;
        ICommonCode _icommon;
        eSolution_HRMSS.HRMSS_Ultil util = new HRMSS_Ultil();
        Guid currentId;
        Guid new_id;
        bool isUpdate = false;
         public FR_ThemThongTinCongTac(bool _isUpdate)
        {
            InitializeComponent();
            isUpdate = _isUpdate;
        }

         public FR_ThemThongTinCongTac(bool _isUpdate, Guid _currentId)
        {
            InitializeComponent();
            isUpdate = _isUpdate;
            currentId = _currentId;
        }


        private void FR_ThemThongTinCongTac_Load(object sender, EventArgs e)
        {
            _IHRM_PROCESS_ASSIGNMENTData = (IHRM_PROCESS_ASSIGNMENTData)Activator.GetObject(typeof(IHRM_PROCESS_ASSIGNMENTData), util.ChuoiPROCESS_ASSIGNMENTData);
            _icommon = (ICommonCode)Activator.GetObject(typeof(ICommonCode), util.Chuoicommon);
        }
        private HRM_PROCESS_ASSIGNMENT lay_thong_tin()
        {
            string diveviec = txtdiveviec.Text;
            string lydodi = txtlydodi.Text;
            string didau = txtdidau.Text;
            string nguoibanhanh = txtnguoibanhanh.Text;
            string soquyetdinh = txtsoquyetdinh.Text;

            DateTime ditungay = dtditungay.DateTime;
            DateTime denngay = dtdenngay.DateTime;
            DateTime ngaybanhanh = dtngaybanhanh.DateTime;

            decimal congtacphi = calcongtacphi.Value;

            HRM_PROCESS_ASSIGNMENT assign = new HRM_PROCESS_ASSIGNMENT();
            assign.AssignmentName = diveviec;
            assign.Reason = lydodi;
            assign.Where = didau;
            assign.Person = nguoibanhanh;
            assign.DecideNumber = soquyetdinh;
            assign.FromDate = ditungay;
            assign.ToDate = denngay;
            assign.Date = ngaybanhanh;
            assign.Money =congtacphi;
            return assign;
        }
        private void load_info()
        {
            DataTable dt = _IHRM_PROCESS_ASSIGNMENTData.HRM_PROCESS_ASSIGNMENT_Get(currentId).Tables[0];
            foreach (DataRow dr in dt.Rows)
            {
                txtdiveviec.Text = dr["AssignmentName"].ToString();
                txtlydodi.Text = dr["Reason"].ToString();
                txtdidau.Text = dr["Where"].ToString();
                txtnguoibanhanh.Text = dr["Person"].ToString();
                txtsoquyetdinh.Text = dr["DecideNumber"].ToString();
                dtditungay.DateTime = DateTime.Parse(dr["FromDate"].ToString());
                dtdenngay.DateTime = DateTime.Parse(dr["ToDate"].ToString());
                dtngaybanhanh.DateTime = DateTime.Parse(dr["Date"].ToString());
                calcongtacphi.Value = decimal.Parse(dr["Money"].ToString());
            }
        }
    }
}